public class Tetromino {
    private int[][] shape;
    private int x;
    private int y;

    public Tetromino(int[][] shape, int x, int y) {
        this.shape = shape;
        this.x = x;
        this.y = y;
    }

    public static Tetromino createLTetromino(int x, int y) {
        int[][] shape = {
                {1, 0},
                {1, 0},
                {1, 1},
        };
        return new Tetromino(shape, x, y);
    }

    public static Tetromino createITetromino(int x, int y) {
        int[][] shape = {
                {0, 0, 0, 0},
                {1, 1, 1, 1},
                {0, 0, 0, 0},
                {0, 0, 0, 0}
        };
        return new Tetromino(shape, x, y);
    }

    public static Tetromino createOTetromino(int x, int y) {
        int[][] shape = {
                {1, 1},
                {1, 1}
        };
        return new Tetromino(shape, x, y);
    }

    public static Tetromino createTTetromino(int x, int y) {
        int[][] shape = {
                {0, 1, 0},
                {1, 1, 1},
                {0, 0, 0}
        };
        return new Tetromino(shape, x, y);
    }

    public static Tetromino createSTetromino(int x, int y) {
        int[][] shape = {
                {0, 1, 1},
                {1, 1, 0},
                {0, 0, 0}
        };
        return new Tetromino(shape, x, y);
    }

    public static Tetromino createZTetromino(int x, int y) {
        int[][] shape = {
                {1, 1, 0},
                {0, 1, 1},
                {0, 0, 0}
        };
        return new Tetromino(shape, x, y);
    }

    public static Tetromino createJTetromino(int x, int y) {
        int[][] shape = {
                {1, 0, 0},
                {1, 1, 1},
                {0, 0, 0}
        };
        return new Tetromino(shape, x, y);
    }

    public int[][] getShape() {
        return this.shape;
    }

    public int getX() {
        return this.x;
    }

    public int getY(){
        return this.y;
    }

    public void setX(int newX) {
        this.x = newX;
    }

    public void setY(int y) {
        this.y = y;
    }

    public void rotate() {
        int[][] rotatedShape = new int[shape[0].length][shape.length];

        for (int row = 0; row < shape.length; row++) {
            for (int col = 0; col < shape[0].length; col++) {
                rotatedShape[col][shape.length - 1 - row] = shape[row][col];
            }
        }

        shape = rotatedShape;
    }
}
